package com.gzqylc.docker.extend.exception;

import com.gzqylc.docker.extend.auth.enums.BusinessExceptionEnums;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author YeFeng
 * @Date 2021 2021/5/11 上午8:53
 * @Version 1.0
 * 业务异常
 * 默认所有 业务异常错误code都是500 不同的是增加了一个业务异常代码 需要处理的就直接根据代码判断就行
 */
@Getter
@Setter
public class ApiBusinessException extends RuntimeException{

    BusinessExceptionEnums businessExceptionEnums;
    /**
     * 目标参数 不会返回给前端，但是会在日志中打印 方便后期排查错误，比如订单错误，可以把订单号放这里
     */
    String[] target;

    public ApiBusinessException(){

    }

    public ApiBusinessException(int code, String message) {
        super(message);
    }

    public ApiBusinessException(String message,BusinessExceptionEnums businessExceptionEnums){
        super(message);
        this.businessExceptionEnums = businessExceptionEnums;
    }

    public ApiBusinessException(BusinessExceptionEnums businessExceptionEnums,String ...target){
        super(businessExceptionEnums.getMessage());
        this.businessExceptionEnums = businessExceptionEnums;
        this.target = target;
    }

    public ApiBusinessException(String message){
        super(message);
        this.businessExceptionEnums = BusinessExceptionEnums.SYSTEM_0000;;
    }

    public ApiBusinessException(String message,String ...target){
        super(message);
        this.businessExceptionEnums = BusinessExceptionEnums.SYSTEM_0000;;
        this.target = target;
    }
}
